#!/bin/bash
##一键配置GIT
read -p "此脚本请放在项目根目录执行" YYY
echo -e "请输入你的邮箱地址"
read mail
echo -e '请输入git用户名[可自定义]'
read user
echo -e '请输入git地址[git协议]'
read url
echo 请直接按回车三次，不要输入任何内容&&ssh-keygen -t rsa -C "$rmail"
echo '请将下面的内容复制下来
	然后输入到git密钥里注册'
cat /root/.ssh/id_rsa.pub
echo 删除HTTPS协议地址&&git remote rm origin
git remote add origin $url
git remote -v
echo "RSAAuthentication yes" >> /etc/ssh/sshd_config&&cat /etc/ssh/sshd_config
sed -i 's/#PubkeyAuthentication/PubkeyAuthentication/g' /etc/ssh/sshd_config
mkdir -p /opt/git/.ssh
p=$(cat /root/.ssh/id_rsa.pub )
echo "$p" > /opt/git/.ssh/authorized_keys
chmod 700 -R /opt/git/.ssh
chmod 600 -R /opt/git/.ssh/authorized_keys
git config --global user.email "$rmail"
git config --global user.name "$user"

